
$(function() {
	
	payment_customer('1');
	
	$('#payment').change(function() {
		var a = $(this).val();
		Pay.payment(a);	
	});
	
	$('#voucher').change(function() {
		var a = $(this).val();
		Pay.voucher(a);
	});
	
	var s = "134123412341";
	// alert(s.substr(0, 5));
	
	_currency($('#currency').val());
	
	$('#currency').change(function() {
		var s = $(this).val();
		_currency(s);
	});
	
	$('#amount').keyup(function() {
		var a = $(this).val();
		var b = $("#currency").find("option:selected").text();
		Currency.upper(a, b, "#label_amount");
	});
	
	$("#label_linkman").hide();
	
	$("#label_payment_linkman").hide();
	$("#label_payment_bank").hide();
	
	$("#label_voucher").hide();
	
	$("#emp").autocomplete(Test.emp);
	
	_ck_default("input[id='emp']:visible", "input[id^='emp_t']:visible");
	
	$('textarea').css("width", 400);
});

function _currency(s) {
	if (s == null || s == '-')　{		
		return false;
	}
	
	var body = { };
	body.currency = s;
	$.post('finance.php?do=Finance.ajax_exchange', body, function(s) {
		exchange = s;
		$('#rate').val(s);
		
		_update();
	});
}

function _update() {
	var a = $("#amount").val();
	var b = $("#currency").find("option:selected").text();

	Currency.upper(a, b, "#label_amount");
		
	_rmb();
}

function _rmb() {
	var a = $("#amount").val();
	var b = $('#rate').val();
	var rmb = fxmul(a, b);
	
	$('#rmb').val(rmb);	
}
